import os
from multiprocessing import Process, Manager
import numpy as np
import signal
import time
from itertools import product
import subprocess

# parameter analysis for SAGloss

import tool

# step 1
r_e_list = [1.0]
r_p_list = [0.1, 1.0, 10, 100]
enlarge_list = [ 5.0]
perplexity_list = [10, 50, 100]
embdim_list = [10, 50, 100]
v_list = [0.001, 0.01, 0.1, 0.3, 0.5, 0.7, 0.9, 1]
dropedgerate_list = [0.00, 0.001, 0.01, 0.05, 0.1]



# # step 2
r_e_list = [1.0]
r_p_list = [100, 150, 300,]
enlarge_list = [ 1, 5, 10]
perplexity_list = [50, 70, 90]
embdim_list = [100,200]
v_list = [0.008,0.01, 0.02,]
dropedgerate_list = [0.00, 0.001, 0.01, 0.05]

# # step 3
r_e_list = [1.0]
r_p_list = [100, 125, 150,]
enlarge_list = [ 1, 5, 10]
perplexity_list = [60, 70, 80]
embdim_list = [200]
v_list = [0.01, 0.011, 0.012, 0.02,]
dropedgerate_list = [0.00, 0.001, 0.01, 0.05]

# # step 3
r_e_list = [1.0]
r_p_list = [100, 125, 150,]
enlarge_list = [ 1, 5, 10, 15]
perplexity_list = [60, 70, 80, 90]
embdim_list = [200]
v_list = [0.01, 0.011, 0.012, 0.016, 0.018, 0.02, 0.022,]
dropedgerate_list = [0.00, 0.001, 0.01, 0.05]

cudalist = [
    # 0,
    # 1,
    2,
    3,
    # 4,
    # 5,
    # 6,
    # 7,
]

changeList = [v_list,dropedgerate_list, embdim_list, perplexity_list, enlarge_list, r_e_list, r_p_list]
paramName = ['v', 'dropedgerate', 'embdim', 'perplexity', 'enlarge', "r_e", "r_p", ]
mainFunc = "./main_graph_wiki.py"
ater = tool.AutoTrainer(
    changeList,
    paramName,
    mainFunc,
    deviceList=cudalist,
    poolNumber=7*len(cudalist),
    name="autotrain",
    waittime=0.1,
)
ater.Run()
